﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApp2
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public int one = 0;
        public int two = 0;
        public int three = 0;

        public String group1 = "同学";
        public String group2 = "亲人";
        public String group3 = "黑名单";

        public MainWindow()
        {
            

            InitializeComponent();
            tongjiFun();
        }

        public void tongjiFun()
        {
            comb.Items.Clear();

            var oneStr1 = group1 + one.ToString();
            comb.Items.Add(oneStr1);

            var oneStr2 = group2 + two.ToString();
            comb.Items.Add(oneStr2);

            var oneStr3 = group3 + three.ToString();
            comb.Items.Add(oneStr3);
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var text = txt.Text;
            Console.WriteLine("输入：" + text);
            var select = comb.SelectedItem;
            Console.WriteLine("选择：" + select);
            if (text==null)
            {
                MessageBox.Show("请输入好友");
            }
            else if (select==null)
            {
                MessageBox.Show("请选择分组");
            }
            else
            {
                // 根据分组统计
                Console.WriteLine("根据分组统计：");
                if (select.ToString().Contains("同学"))
                {
                    list1.Items.Add(text);
                    one += 1;
                    tongjiFun();
                }
                else if (select.ToString().Contains(group2))
                {
                    list2.Items.Add(text);
                    two += 1;
                    tongjiFun();
                }
                else if(select.ToString().Contains(group3))
                {
                    list3.Items.Add(text);
                    three += 1;
                    tongjiFun();
                }
            }
        }
    }
}
